call

public abstract T call<T>(String methodName, Array<Object> args)

Executes the function with the given methodName and the args in the JavaScript object. This method blocks current thread execution until the function finishes its execution. If the function raises an exception, then JsException with an error message that describes the reason of the exception will be thrown. Same error message will be printed in JavaScript Console.

The type mapping rules are the following:


| Java               | JavaScript                    |
|--------------------|-------------------------------|
| Number             | Double                        |
| String             | String                        |
| Boolean            | Boolean                       |
| null               | null                          |
| JsObject           | Object                        |
| Node               | Node                          |
| List<?>            | Array or Proxy Object         |
| Set<?>             | Set or Proxy Object           |
| Map<?,?>           | Map or Proxy Object           |
| byte[]             | ArrayBuffer                   |
| Object             | Proxy Object                  |

If you pass a non-primitive Java object to JavaScript, it will be converted into a "proxy" JavaScript object. Method and property calls to this object will be delegated to the Java object. For security reasons, JavaScript can access only those methods and fields of the injected Java object that are explicitly marked as accessible either using the JsAccessible annotation or via the JsAccessibleTypes class.

Java collections that are not made accessible to JavaScript using the JsAccessible annotation or via the JsAccessibleTypes class are converted to JavaScript collections. The content of the converted collection is a deep copy of the Java collection. Modifications of the converted collection in JavaScript do not affect the collection in Java.

Java collections that are made accessible to JavaScript using the JsAccessible annotation or via the JsAccessibleTypes class are wrapped into a JavaScript proxy object. Such proxy objects can be used to modify the collection in Java.

The type mapping rules are the following:

| JavaScript         | Java           |
|--------------------|----------------|
| Number             | Double         |
| String             | String         |
| Boolean            | Boolean        |
| null and undefined | null           |
| Node               | JsObject, Node |
| ArrayBuffer        | JsArrayBuffer  |
| Array              | JsArray        |
| Set                | JsSet          |
| Map                | JsMap          |
| Object             | JsObject       |
| Proxy Object       | Object         |

Proxy objects are mapped to the corresponding injected Java object.

Parameters

methodName

a string that represents a function name

args

the input arguments that will be converted according to the mapping rules

<T>

the result of the JavaScript function execution

Throws

when an error occurs during function execution

when args contains an unsupported type

when the JavaScript object is already disposed or invalid